<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="src/styles.css">
<title>Main Page</title>
</head>
<body>
<div id="wrap">
<div id="header">
	<div class="title">Tractors</div>
	<!-- <img src="http://tractorhaven.com/wp-content/uploads/2011/05/5530_4wd.jpg">  -->
</div>

<div class="sidebar">
        <a href="addtraktor.php">Add</a><br/>
        <a href="edittractor.php">Edit</a><br/>
        <a href="mainpage.php">Remove</a><br/>
        <a href="mainpage.php">Buy</a>
</div>
<div class="tractors">
<table>
	<tr>
		<th>Select</th>
		<th>Tractor Name</th>
		<th>Brand</th>
		<th>Price</th>
	</tr>
<?php

	$db_connect=mysqli_connect("localhost","root","","tractors");
	//echo "passed";
	
	$query="select
			name,
			m.modelname as Model,
			price
			from tractor
			inner join model m using(model_id)";
	
	$result=mysqli_query($db_connect,$query) or die(mysqli_error($db_connect));
	
	if(mysqli_num_rows($result)>0){
		while($row=mysqli_fetch_assoc($result)){
			echo "<tr><td><input type=\"checkbox\" name=\"check\"/></td>";
			echo "<td>".$row['name']."</td>";
			echo "<td>".$row['Model']."</td>";
			echo "<td>".$row['price']."</td></tr>";
		}
	}else{
		echo "<p>No Data found!</p>";
	}
	
	mysqli_close($db_connect);

?>
</div>
</div>
</body>
</html>